<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.6.3/angular.min.js"></script>
</head>
<body>

<div ng-app="myApp" ng-controller="siteCtrl"> 


<button ng-click="getClick()">GET请求</button>
<ul>
    <li ng-repeat="item in data1">
     <p>  {{item.file_name}} </p>
     <p>  {{item.id}} </p>
     <p>  {{item.info_hash}}</p>
     <p>  {{item.size}}</p>
     <p>  {{item.url}}</p>
    </li>
  </ul>

<button ng-click="postClick()">post请求</button>
<ul>
    <li ng-repeat="item in data2">
     <p>  {{item.file_name}} </p>
     <p>  {{item.id}} </p>
     <p>  {{item.info_hash}}</p>
     <p>  {{item.size}}</p>
     <p>  {{item.url}}</p>
    </li>
  </ul>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('siteCtrl', function($scope, $http) {
 
    let baseUrl ='http://biz.chinatorrent.cn/api/v1/';
    let token = '0HeyLOmM9lKJTwAtZ6RNrkoXIrcjqp';
    let magnet_url ='magnet:?xt=urn:btih:e0fdb0e89d69f2edd6e280cde9d73ac0df5ce4de'
    $scope.getClick=function(){
    $http({
      method: 'GET',
      Authorization: 'Bearer '+token,
      url: baseUrl+'refreshtask/?infohash=278b90dc9966f3f317de2300a92d3084b5cd9a7a',
    }).then(function successCallback(response) {
          // 请求成功执行代码
          $scope.data1 = response.data.file_list;
          console.log(response);
      }, function errorCallback(error) {
          // 请求失败执行代码
          console.log(error);
    });
   };
   
   $scope.postClick=function(){
    $http({
      method: 'POST',
      Authorization: 'Bearer '+token,
      data:{
        'magnet_url':magnet_url
      },
      url: baseUrl+'udownload/',
    }).then(function successCallback(response) {
          // 请求成功执行代码
          console.log(response);
          $scope.data2 = response.data.file_list;
      }, function errorCallback(error) {
          // 请求失败执行代码
          console.log(error);
    });
   }
});
</script>

</body>
</html>